<%@page import="com.glowdayz.common.DBHandler"%>
<%@page import="java.util.ArrayList"%>
<%@ page import="com.glowdayz.glowmee.dao.ThirdCategoryDAO"%>
<%@ page import="com.glowdayz.glowmee.cmd.ThirdCategoryCMD"%>
<%@ page language="java" contentType="text/xml; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ page trimDirectiveWhitespaces="true" %>
<%
	String second = request.getParameter("second");

	if (second.equals("default")) {
		
	%>
<?xml version="1.0" encoding="utf-8" ?>
<third>
	<item>
		<idThirdCategory>default</idThirdCategory>
		<thirdCategoryText>- 2차를 먼저 선택하여 주세요 -</thirdCategoryText>
	</item>
</third>
	<%	
		return;
	}
	DBHandler.getInstance().connect();
	ThirdCategoryDAO dao = ThirdCategoryDAO.getInstance();
	ArrayList<ThirdCategoryCMD> cmd = dao.getThirdCategoryList(1, -1, "idSecondCategory=" + second);
	if (cmd != null) {
%>
<?xml version="1.0" encoding="utf-8" ?>
<third>
	<item>
		<idThirdCategory>default</idThirdCategory>
		<thirdCategoryText>- 3차카테고리 -</thirdCategoryText>
	</item>
	<%
		for (int i=0; i<cmd.size(); i++) {
			ThirdCategoryCMD temp = cmd.get(i);
	%>
	<item>
		<idThirdCategory><%= temp.getIdThirdCategory() %></idThirdCategory>
		<thirdCategoryText><%= temp.getThirdCategoryText() %></thirdCategoryText>
	</item>
	<%
		}
		DBHandler.getInstance().disconnect();
	%>
</third>
<%
	} else {
%>
<?xml version="1.0" encoding="utf-8" ?>
<third>
	<item>
		<idThirdCategory>default</idThirdCategory>
		<thirdCategoryText>- 해당 2차 카테고리 데이터없음 -</thirdCategoryText>
	</item>
</third>
<%}%>